﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="VTV.TaskManagementSystem.WebApp.Admin.Tasks.List" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../../Styles/Main.css" rel="stylesheet" />
    <script src="../../Scripts/Task.js" ></script>
</head>
<body>
    <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Viewport runat="server"
            ID="viewPort" Layout="Border">
            <Items>
                <ext:Panel runat="server"
                    ID="pnlList"
                    Title="Danh sách đầu việc"
                    Region="Center"
                    Layout="Fit"
                    Frame="True">
                    <Items>
                        <ext:GridPanel runat="server"
                            ID="gridTask" EmptyText="No data" Margins="2 0 0 0" >
                            <TopBar>
                                <ext:Toolbar ID="Toolbar1" runat="server">
                                    <Items>
                                        <ext:Button runat="server" ID="btnAdd" Text="Thêm mới" Icon="ReportAdd" OnDirectClick="btnAdd_Click" />
                                    </Items>
                                </ext:Toolbar>
                            </TopBar>
                            <Store>
                                <ext:Store runat="server" ID="storeEmployee" PageSize="10" WarningOnDirty="True"
                                    OnReadData="storeEmployee_OnReadData">
                                    <Model>
                                        <ext:Model ID="Model1" runat="server" IDProperty="ID">
                                            <Fields>
                                                <ext:ModelField Name="TaskID" Mapping="TaskID" Type="Int" />
                                                <ext:ModelField Name="TaskName" Mapping="TaskName" Type="String" />
                                                <ext:ModelField Name="Descriptions" Mapping="Descriptions" Type="String" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                    <Proxy>
                                        <ext:PageProxy />
                                    </Proxy>
                                </ext:Store>
                            </Store>
                            <ColumnModel>
                                <Columns>
                                    <ext:Column runat="server" Text="Tên" DataIndex="TaskName" Flex="1" />
                                    <ext:Column runat="server" Text="Mô tả công việc" DataIndex="Descriptions" Flex="1" />

                                    <ext:CommandColumn ID="CommandColumn1" runat="server" Width="60">
                                        <Commands>
                                            <ext:GridCommand Icon="Delete" CommandName="Delete">
                                                <ToolTip Text="Xóa" />
                                            </ext:GridCommand>
                                            <ext:CommandSeparator />
                                            <ext:GridCommand Icon="NoteEdit" CommandName="Edit">
                                                <ToolTip Text="Sửa" />
                                            </ext:GridCommand>
                                        </Commands>

                                        <DirectEvents>
                                            <Command OnEvent="gridTask_OnCommand">
                                                <ExtraParams>
                                                    <ext:Parameter Name="TaskID" Mode="Raw" Value="record.data.TaskID" />
                                                    <ext:Parameter Name="Command" Mode="Raw" Value="command" />
                                                </ExtraParams>
                                            </Command>
                                        </DirectEvents>
                                    </ext:CommandColumn>
                                </Columns>
                            </ColumnModel>
                            <SelectionModel>
                                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Single">
                                    <DirectEvents>
                                        <Select OnEvent="gridTask_OnRowSelected">
                                            <ExtraParams>
                                                <ext:Parameter Name="TaskID" Mode="Raw" Value="record.data.TaskID" />
                                                <ext:Parameter Name="TaskName" Mode="Raw" Value="record.data.TaskName"/>
                                            </ExtraParams>
                                        </Select>
                                    </DirectEvents>
                                </ext:RowSelectionModel>
                            </SelectionModel>
                            <BottomBar>
                                <ext:PagingToolbar ID="pagingToolbar" runat="server" FirstText="Trang đầu" PrevText="Trang trước"
                                    NextText="Trang tiếp" LastText="Trang cuối" BeforePageText="Trang" AfterPageText="trên {0}"
                                    DisplayMsg="Danh sách {0} - {1} / tổng số {2}" />
                            </BottomBar>
                        </ext:GridPanel>
                    </Items>
                </ext:Panel>

                <ext:Panel runat="server" ID="pnlTeamList"
                    BodyPadding="2"
                    AutoScroll="True"
                    Height="400"
                    Region="South"
                    Title="Phân việc theo nhóm"
                    Layout="Fit"
                    Collapsible="true"
                    Split="true"
                    Frame="True"
                    Margins="5 0 0 0">
                    <Items>
                        <ext:GridPanel runat="server" ID="gridTeam" EmptyText="No data">
                            <TopBar>
                                <ext:Toolbar ID="Toolbar2" runat="server">
                                    <Items>
                                        <ext:Button runat="server" ID="btnAddTeam" Text="Thêm mới" Icon="Add" OnDirectClick="btnAddTeam_Click" />
                                    </Items>
                                </ext:Toolbar>
                            </TopBar>
                            <Store>
                                <ext:Store runat="server" ID="storeTeamList">
                                    <Model>
                                        <ext:Model runat="server" IDProperty="ID">
                                            <Fields>
                                                <ext:ModelField Name="TeamName" Mapping="TeamName" Type="String" />
                                                <ext:ModelField Name="StartDate" Mapping="StartDate" Type="Date" />
                                                <ext:ModelField Name="ExpectedEndDate" Mapping="ExpectedEndDate" Type="Date" />
                                                <ext:ModelField Name="ActualEndDate" Mapping="ActualEndDate" Type="Date" />
                                                <ext:ModelField Name="Status" Mapping="Status" Type="String" />
                                                <ext:ModelField Name="Comment" Mapping="Comment" Type="String" />

                                                <ext:ModelField Name="TaskID" Mapping="TaskID" Type="Int" />
                                                <ext:ModelField Name="TeamID" Mapping="TeamID" Type="Int" />
                                                <ext:ModelField Name="TaskTeamID" Mapping="TaskTeamID" Type="Int" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <ColumnModel>
                                <Columns>
                                    <ext:Column runat="server" Text="Tên nhóm" DataIndex="TeamName" Width="250" />
                                    <ext:Column runat="server" Text="Trạng thái" DataIndex="Status" Width="120">
                                        <Renderer Fn="status1" />
                                    </ext:Column>
                                    <ext:DateColumn ID="DateColumn1" runat="server" Text="Ngày bắt đầu" DataIndex="StartDate" Format="dd-MM-yyyy" Width="100" />
                                    <ext:DateColumn runat="server" Text="Ngày kết thúc" DataIndex="ExpectedEndDate" Format="dd-MM-yyyy" Width="100" />
                                    <ext:DateColumn runat="server" Text="Thực tế" DataIndex="ActualEndDate" Format="dd-MM-yyyy" Width="100" />
                                    <ext:Column runat="server" Text="Ghi chú" DataIndex="Comment" Flex="1" />

                                    <ext:CommandColumn runat="server" Width="60">
                                        <Commands>
                                            <ext:GridCommand Icon="Delete" CommandName="Delete">
                                                <ToolTip Text="Xóa" />
                                            </ext:GridCommand>
                                            <ext:CommandSeparator />
                                            <ext:GridCommand Icon="NoteEdit" CommandName="Edit">
                                                <ToolTip Text="Sửa" />
                                            </ext:GridCommand>
                                        </Commands>

                                        <DirectEvents>
                                            <Command OnEvent="gridTeamList_OnCommand">
                                                <ExtraParams>
                                                    <ext:Parameter Name="TaskID" Mode="Raw" Value="record.data.TaskID" />
                                                    <ext:Parameter Name="TeamID" Mode="Raw" Value="record.data.TeamID" />
                                                    <ext:Parameter Name="TaskTeamID" Mode="Raw" Value="record.data.TaskTeamID" />
                                                    <ext:Parameter Name="Command" Mode="Raw" Value="command" />
                                                </ExtraParams>
                                            </Command>
                                        </DirectEvents>
                                    </ext:CommandColumn>
                                </Columns>
                            </ColumnModel>
                        </ext:GridPanel>
                    </Items>
                </ext:Panel>
            </Items>
        </ext:Viewport>

        <ext:Window runat="server"
            ID="windowDetailTask"
            Icon="Report"
            Title="Thông tin nhóm"
            Width="380"
            Height="190"
            Hidden="True"
            Closable="False"
            Resizable="False"
            BodyStyle="background-color:#fff;"
            BodyPadding="5"
            Layout="Form">
            <Items>
                <ext:Panel ID="Panel1" runat="server"
                    BodyPadding="5"
                    Border="False"
                    Header="False"
                    Layout="AnchorLayout">
                    <Items>
                        <ext:Panel
                            Border="False"
                            Header="False"
                            AnchorHorizontal="100%"
                            Layout="FormLayout">
                            <Items>
                                <ext:TextField runat="server" ID="txtName" FieldLabel="Tên công việc" />
                                <ext:TextArea runat="server" ID="txtNote" Height="65" AutoScroll="True" FieldLabel="Mô tả công việc" MarginSpec="0 0 10 0" />
                                <ext:Hidden runat="server" ID="TaskID" />
                            </Items>
                        </ext:Panel>
                    </Items>
                    <Buttons>
                        <ext:Button runat="server" ID="btnSave" Text="Lưu" Icon="Disk">
                            <DirectEvents>
                                <Click OnEvent="btnSave_Click">
                                    <EventMask ShowMask="true" Msg="Đang lưu..." MinDelay="500" />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button ID="btnCancel" Text="Quay lại" Icon="BuildCancel" OnClientClick="#{windowDetailTask}.close();">
                            <Listeners>
                                <Click Fn="ClearAllTextbox" Handler=""></Click>
                            </Listeners>
                        </ext:Button>
                    </Buttons>
                </ext:Panel>


            </Items>
        </ext:Window>

        <ext:Window runat="server"
            ID="windowDetailTeam"
            Icon="Report"
            Width="380"
            Height="270"
            Hidden="True"
            Closable="False"
            Resizable="False"
            BodyStyle="background-color:#fff;"
            BodyPadding="5"
            Layout="Form">
            <Items>
                <ext:Panel ID="Panel2" runat="server"
                    BodyPadding="5"
                    Border="False"
                    Header="False"
                    Layout="AnchorLayout">
                    <Items>
                        <ext:Panel
                            Border="False"
                            Header="False"
                            AnchorHorizontal="100%"
                            Layout="FormLayout">
                            <Items>
                                <ext:ComboBox ID="cbbTeamList" runat="server"
                                    DisplayField="Name"
                                    ValueField="TeamID"
                                    PageSize="5"
                                    TypeAhead="true"
                                    HideBaseTrigger="false"
                                    AllowBlank="False"
                                    MinChars="1"
                                    FieldLabel="Nhóm">
                                    <ListConfig LoadingText="Đang tìm kiếm...">
                                        <ItemTpl ID="ItemTpl1" runat="server">
                                            <Html>
                                                <div class="search-item">
                                                    <p><h3><name>{Name}</name></h3></p>
                                                    <p><h3><note>{Note}</note></h3></p>
                                                </div>
                                            </Html>
                                        </ItemTpl>
                                    </ListConfig>

                                    <Store>
                                        <ext:Store runat="server" AutoLoad="False" ID="storeTeam" OnReadData="storeTeam_OnReadData" PageSize="5" WarningOnDirty="False">
                                            <Model>
                                                <ext:Model ID="Model2" runat="server" IDProperty="ID">
                                                    <Fields>
                                                        <ext:ModelField Name="TeamID" Mapping="TeamID" Type="Int" />
                                                        <ext:ModelField Name="Name" Mapping="Name" Type="String" />
                                                        <ext:ModelField Name="Note" Mapping="Note" Type="String" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                            <Proxy>
                                                <ext:PageProxy />
                                            </Proxy>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                                <ext:DateField runat="server" ID="txtStartDate" FieldLabel="Ngày bắt đầu" Format="dd/MM/yyyy" />
                                <ext:DateField runat="server" ID="txtExpectedEndDate" FieldLabel="Ngày kết thúc" Format="dd/MM/yyyy" />
                                <ext:TextArea runat="server" ID="txtComment" Height="65" AutoScroll="True" FieldLabel="Nhận xét" />
                                <ext:RadioGroup runat="server" FieldLabel="Trạng thái">
                                    <Items>
                                        <ext:Radio ID="radioStatusWorking" runat="server" BoxLabel="Đang làm" Checked="True" />
                                        <ext:Radio ID="radioStatusDone" runat="server" BoxLabel="Đã hoàn thành" Checked="False" />
                                    </Items>
                                </ext:RadioGroup>
                                <ext:Hidden runat="server" ID="hiddenTaskID" />
                                <ext:Hidden runat="server" ID="hiddenTeamID" />
                                <ext:Hidden runat="server" ID="hiddenTaskTeamID" />
                            </Items>
                        </ext:Panel>
                    </Items>
                    <Buttons>
                        <ext:Button runat="server" ID="btnSaveTeam" Text="Lưu" Icon="Disk">
                            <DirectEvents>
                                <Click OnEvent="btnSaveTeam_Click">
                                    <EventMask ShowMask="true" Msg="Đang lưu..." MinDelay="500" />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button Text="Quay lại" Icon="BuildCancel" OnClientClick="#{windowDetailTeam}.close();">
                            <Listeners>
                                <Click Fn="ClearAll_TeamForm" Handler=""></Click>
                            </Listeners>
                        </ext:Button>
                    </Buttons>
                </ext:Panel>


            </Items>
        </ext:Window>
    </form>
</body>
</html>

